<?php
	session_start();

	if (!isset($_SESSION['login']) && !$_SESSION['login'] == true) {
		header ("Location: index.php");
	}
	include ("LangHeader.php");
	include ("config.php");

	if(isset($_GET['ID']))
	{
		$id = $_GET['ID'];
	}
	else
	{
		header ("Location: listusers.php");
	}

?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="style.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

<title>Sales Makeover</title>
</head>

<body>
	<div class="container_head">
		<?php include("header.html"); ?>
	</div>
	<div class="container">
		<div class="editCompanyHeadline tr" key="show_User">Visar användare</div>
		<div class="content_edit" id="content_edit">
			
				<?php
					$stmt = $con->prepare('SELECT User.ID, User.Name, User.Login, User.Active, Company.Name AS CompanyName FROM User INNER JOIN Company ON User.CompanyID = Company.ID WHERE User.ID = ?');
					$stmt->bind_param('i', $id);
					$stmt->execute();
					
					$employeeresult = $stmt->get_result();
					$employeerow = $employeeresult->fetch_assoc();

					echo "<div class='editCompanyName'>";
					echo $employeerow['Name'];
					echo "</div><br/>";
					echo "<div class='editCompanyInfo'>";
					echo $employeerow['CompanyName'];
					echo "<br/>";
					echo $employeerow['Login'];
					echo "<br/>";
					echo "</div>";
					
					echo "<br/>";
					echo "<br/>";
					echo "<b><div style='margin-left: 15px;margin-bottom:15px;' class= 'tr_back' key='show_Innovations'>";
					echo $employeerow['Name']." ";
					echo "</div></b>";
					$stmt = $con->prepare('SELECT ID, Name FROM Innovation WHERE OwnerID = ?');
					$stmt->bind_param('i', $id);
					$stmt->execute();
					$innovationresult = $stmt->get_result();
					//$innovationresult = mysqli_query($con,"SELECT ID, Name FROM Innovation WHERE OwnerID = '$id'");
					echo "<div style='height:250px;margin-left: 15px;overflow-y:scroll;' >";
					echo "<div style='width: 100%;border-bottom: 1px solid #333333;'>";
					while($row = $innovationresult->fetch_assoc())
					{
						
						echo "<div style='border-top:1px solid #333333; border-left: 1px solid #333333; border-right: 1px solid #333333;padding: 20px;'>";
						echo $row['Name'];
						echo "</div>";
						
						
					}
					echo "</div>";
					echo "</div>";
				?>
				
			<span><div class="button_black tr" key="Back" style="float:left;margin-left: 15px;margin-top:10px;" onclick="javascript:location.href='listusers.php'">Tillbaka</div></span>
			
		</div>
	</div>
	<footer>
<div class = 'WaterMark'>© 2014 Sales Makeover</div>
</footer>

</body>

</html>
<script type="text/javascript">

</script>